import numpy as np

a = np.array([150, 166, 183, 170])
print(a + 3)

print("a + 3:", a + 3)
print("a - 3:", a - 3)
print("a * 3:", a * 3)
print("a / 3:", a / 3)



print("************************")

a = np.array([
    [1, 2],
    [3, 4]
])
b = np.array([
    [5, 6],
    [7, 8]
])

print(a.dot(b))  # 直接用一个矩阵 dot 另一个
print(np.dot(a, b))  # 用 np.dot(a, b) 把两个矩阵包起来

print("************************")

a = np.array([150, 166, 183, 170])
print("最大：", np.max(a))
print("最小：", a.min())

print(a.sum())

print("************************")

a = np.array([150, 166, 183, 170])
print("累乘：", a.prod())
print("总数：", a.size)

print("************************")

a = np.array([0, 1, 2, 3])
print("非零总数：", np.count_nonzero(a))

print("************************")

month_salary = [1.2, 20, 0.5, 0.3, 2.1]
print("平均工资：", np.mean(month_salary))
print("工资中位数：", np.median(month_salary))

print("标准差：", np.std(month_salary))

print("************************")

a = np.array([150, 166, 183, 170])
name = ["小米", "OPPO", "Huawei", "诺基亚"]
# np.argmax() 和 np.argmin(),求最大和最小的索引
high_idx = np.argmax(a)
low_idx = np.argmin(a)
print(high_idx)
print(low_idx)
print("{} 最高".format(name[high_idx]))
print("{} 最矮".format(name[low_idx]))

print("************************")

a = np.array([150.1, 166.4, 183.7, 170.8])
print("ceil:", np.ceil(a))  # 向上取整(天花板)
print("floor:", np.floor(a))  # 向下取整（地板）

print("clip:", a.clip(160, 180))  # 可以用 np.clip() 来做上下界限的值截取。
